<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bor{
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <div id="app">
        <div @click='add'>我是app盒子{{msg}}</div>
        <common-head></common-head>
        <common-head></common-head>
        <common-head></common-head>
    </div>
</body>
<script src="./vue.js"></script>
<script>
    const CommonHead={
        template:`
            <div @click='add' class='bor'>我是全局组件
                {{ msg }}
            <logo-son></logo-son>
            </div>
            
        `,
        data(){
            return {
                msg:12
            }
        },
        methods:{
            add(){
                this.msg++
                console.log(this)
            }
        },
        watch:{
            msg(){
                console.log('我是监听组件的msg')
            }
        },
        components:{
            LogoSon:{
                template:`
                    <div @click.stop='msg++'>我是子组件 {{msg}}</div>
                `,
                data(){
                    return{
                        msg:12
                    }
                }
            }
        }
    }
    Vue.component('CommonHead',CommonHead)
    const vm=new Vue({
        el:'#app',
        data:{
            msg:12
        },
        methods:{
            add(){
                this.msg++
                console.log(this)
            }
        },
        watch:{
            msg(){
                console.log('我是监听app的msg')
            }
        }


    })
</script>
</html>